package com.mybatis.flex.service.impl;

import com.mybatis.flex.entity.Account;
import com.mybatis.flex.mapper.AccountMapper;
import com.mybatis.flex.service.IACcountService;
import com.mybatisflex.spring.service.impl.CacheableServiceImpl;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

@Service
@CacheConfig(cacheNames = "account")
public class AccountServiceImpl extends CacheableServiceImpl<AccountMapper, Account> implements IACcountService {

    // 根据主键缓存数据
    @Override
    @Cacheable(key = "#id")
    public Account getById(Serializable id) {
        return super.getById(id);
    }

    @Override
    @Cacheable(key = "#root.methodName")
    public List<Account> list() {
        return super.list();
    }

}
